<%-- 
    Document   : do-login
    Created on : 2013-10-25, 15:57:31
    Author     : 赵远
--%>

<%@page import="java.util.Hashtable"%>
<%@page import="java.util.Vector"%>
<%@page import="com.suypower.carManage.comm.ConstUtil"%>
<%@page import="com.jarp.db.DAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
String userName=request.getParameter("txtLogin");
String password=request.getParameter("txtPassword");
String sql="SELECT * FROM tb_user t WHERE t.name='"+userName+"'";
DAO dao=new DAO();
try{
Vector v=dao.getDataSet(ConstUtil.DBNAME, sql);
if(v!=null){
    Hashtable hash=(Hashtable)v.get(0);
    if(password.equals(hash.get("PASSWORD"))){
        response.sendRedirect("menu.action");
        session.setAttribute("userid",hash.get("USERID") );
        session.setAttribute("username", hash.get("USERNAME"));
    }else{
        response.sendRedirect("login.jsp?errorInfo=1");
    }
}else{
    response.sendRedirect("login.jsp?errorInfo=2");
}
}catch(Exception e){
response.sendRedirect("login.jsp?errorInfo=3");
}
%>

